package com.ruoyi.Config;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.messaging.handler.annotation.MessageMapping;
import org.springframework.messaging.simp.SimpMessagingTemplate;
import org.springframework.stereotype.Controller;

/**
 * @Description:
 * @Author: 吕宇宏
 * @Date: 2024/6/14 14:25
 */
@Controller
public class WebSocketController {

    @Autowired
    private SimpMessagingTemplate simpMessagingTemplate;

    @MessageMapping("/sendMessage")
    public void sendMessage(String message) {
        simpMessagingTemplate.convertAndSend("/topic/public", message);
    }
}
